<!DOCTYPE html>
<html lang="zxx">

<head>
  <title>个人信息</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta charset="utf-8">
  <meta name="keywords" content=""/>
  <link href="/css/style2.css" rel='stylesheet' type='text/css' />
	<link href="http://fonts.googleapis.com/css?family=Abhaya+Libre:400,500,600,700,800" rel="stylesheet">
  <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
</head>

<body>
  <header>
    <h1>完善个人信息</h1>
  </header>
  <div class="w3ls-contact">
    <!-- form starts here -->
    <form id="form1" method="post">
      <div class="agile-field-txt">
        <label>
          姓名 :</label>
        <div class="mr_agilemain">
          <div class="left-wthree">
            <input type="text" id="userName" name="userName" placeholder=" " required="">
          </div>
        </div>
      </div>
      <div class="agile-field-txt">
        <label>
         手机号:</label>
        <input type="text" id="tel" name="tel" placeholder=" " required="" />
      </div>
      <div class="agile-field-txt">
        <label>
         学号:</label>
        <input type="text" id="carId" name="carId" placeholder=" " required="" />
      </div>
      <div class="w3ls-contact  w3l-sub" style="padding: 80px 0 0;">
        <input  onclick="start()" value="开始评教">
      </div>
    </form>
  </div>
</body>
<!-- //Body -->

<script>
  window.onload = function(){
    var userId = localStorage.getItem("userId")
    if(userId){
     
      window.location=`/Quser?userId=${userId}`
    }
  }
  function start(){
    let data = {};
    data.userName = $("#userName").val()
    data.tel = $("#tel").val()
    data.carId = $("#carId").val()
    console.log(data)
    $.ajax({url:'/api/addUsers',data:data,method:'post',success:(res)=>{
      localStorage.setItem("userId", res);
      alert("登录成功，开始评教吧")
       window.location=`/QselectTeacher?userId=${res}`
    },fail:(res)=>{
      console.log(res)
    }})
  }
  </script>
</html>